/**
 * SiteInfoDAOImpl.java
 * 
 * 
 * lssrc.com
 * 2012-12-19
 */
package com.lssrc.pams.dao.impl;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.lssrc.pams.dao.SiteInfoDAO;
import com.lssrc.pams.domain.SiteInfo;

@Repository("siteInfoDAO")
public class SiteInfoDAOImpl extends BaseDAOImpl implements SiteInfoDAO {

	@SuppressWarnings("unchecked")
	public List<SiteInfo> findByGroup(SiteInfo siteInfo) {
		List<SiteInfo> siteInfos = null;
		try {
			Session session = getSessionFactory().getCurrentSession();
			Transaction transaction = session.beginTransaction();
			siteInfos = session.createCriteria(SiteInfo.class).add(Restrictions.eq("siteinfoGroup", siteInfo.getInfoGroup())).setProjection(Projections.groupProperty("siteinfoGroup")).addOrder(Order.asc("siteinfoName")).list();
			transaction.commit();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		return siteInfos;
	}

}
